<template>
  <view class="foot">
    <view class="bind" @click="addshow">
      <image class="foot_img" src="@/static/cart.png"></image>
      <view class="cart_tit" v-if="sum_count === 0">当前未选购商品</view>
      <view class="cart_pc" wx:else>
        <view class="sumprice">
          ￥
          <text class="sumprice_text">{{ sum_price }}</text>
        </view>
        <view class="cart_count">已选{{ sum_count }}件</view>
      </view>
    </view>
    <view v-if="sum_count === 0" class="btns">去结算</view>
    <view v-else class="bnt" @click="postcart">去结算</view>
  </view>
</template>

<script lang="ts" setup>
import { to } from '@/utils/uniapi';
const props = defineProps(['sum_price', 'sum_count', 'show']);
const emit = defineEmits(['addshow']);
function addshow() {
  const shows = !props.show;
  emit('addshow', { shows });
}
async function postcart() {
  uni.showModal({
    title: '提示',
    content: '你确定结算当前购物车吗？',
    complete: async (res) => {
      if (res.confirm) {
        to('/user/order/order');
      }
    }
  });
}
</script>

<style scoped>
.foot {
  width: 670rpx;
  height: 80rpx;
  background: #4c4b4b;
  position: fixed;
  bottom: 0;
  z-index: 10;
  left: 50%;
  transform: translate(-50%);
  border-radius: 30rpx;
  display: flex;
}
.bind {
  width: 526rpx;
  padding-left: 120rpx;
  padding-right: 14rpx;
  box-sizing: border-box;
  display: flex;
  line-height: 80rpx;
}
.cart_tit {
  font-size: 32rpx;
  font-weight: 400;
  font-family: Source Han Sans CN-Regular, Source Han Sans CN;
  color: #9f9a9a;
}
.cart_pc {
  display: flex;
  width: 100%;
}
.sumprice {
  font-size: 28rpx;
  font-weight: 500;
  color: #ffffff;
}
.sumprice_text {
  font-size: 44rpx;
  font-family: Source Han Sans CN-Bold, Source Han Sans CN;
  font-weight: 700;
  color: #ffffff;
}
.cart_count {
  font-size: 28rpx;
  font-weight: 400;
  color: #fecd57;
  margin-left: auto;
}
.bnt {
  width: 144rpx;
  height: 80rpx;
  background: #c32136;
  border-radius: 30rpx;
  text-align: center;
  font-size: 32rpx;
  font-weight: 500;
  color: #ffffff;
  line-height: 80rpx;
}
.btns {
  width: 144rpx;
  height: 80rpx;
  border-radius: 30rpx;
  line-height: 80rpx;
  text-align: center;
  font-size: 32rpx;
  font-family: Source Han Sans CN-Regular, Source Han Sans CN;
  font-weight: 400;
  color: #9f9a9a;
  background-color: #6d6b6b;
}
.foot_img {
  width: 66rpx;
  height: 96rpx;
  position: absolute;
  top: -22rpx;
  left: 20rpx;
}
</style>
